@extends('admin.layout.app')
<link rel="stylesheet" href="{{asset('css/fontawesome-iconpicker.min.css')}}"/>

@section('content')
    <div style="padding: 20px; background-color: #F2F2F2;">
        <div class="layui-row layui-col-space15">

            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-header">修改菜单</div>
                    <div class="layui-card-body">
                        <form class="layui-form" method="post" action="/menu/update">
                            <div class="layui-form-item">
                                <label class="layui-form-label">父菜单</label>
                                <div class="layui-input-block">
                                    <select name="parent_id" lay-filter="aihao"
                                        @if($ownMenu->parent_id==0) disabled @endif>
                                        <option value="0">无</option>
                                        @foreach($menu as $m)
                                            @if($m->parent_id==0)
                                                @if($ownMenu->parent_id==$m->id)
                                                    <option value="{{$m->id}}" selected>{{$m->name}}</option>
                                                @else
                                                    <option value="{{$m->id}}">{{$m->name}}</option>
                                                @endif
                                            @endif
                                        @endforeach
                                    </select>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <label class="layui-form-label">名称</label>
                                <div class="layui-input-block">
                                    <input type="text" name="name" autocomplete="off" placeholder="请输入菜单标题" required
                                           value="{{$ownMenu->name}}"
                                           class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <span class="input-group-addon layui-form-label"><i
                                            class="fas fa-address-book"></i></span>
                                <input data-placement="right"
                                       required
                                       class="layui-input-inline layui-input form-control icp icp-auto iconpicker-element iconpicker-input"
                                       value="{{$ownMenu->icon}}" type="text" name="icon">
                                <div class="layui-form-mid layui-word-aux">
                                    <i class="fas fa-info-circle"></i>
                                    <a href="http://fontawesome.io/icons/" target="_blank">更多点我</a>
                                </div>
                            </div>

                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">URI</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="uri" placeholder="URI地址" autocomplete="off" value="{{$ownMenu->uri}}" required class="layui-input">
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label">排序ID</label>
                                    <div class="layui-input-inline">
                                        <input type="text" name="sort" placeholder="0-999" autocomplete="off" value="{{$ownMenu->sort}}" required class="layui-input">
                                    </div>
                                    <div class="layui-form-mid layui-word-aux">
                                        <i class="fas fa-info-circle"></i>
                                        数字小的排前面
                                    </div>
                                </div>
                            </div>

                            <input type="hidden" value="{{$ownMenu->id}}" name="id"/>

                            <div class="layui-form-item">
                                <div class="layui-inline">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-inline">
                                        <button class="layui-btn" lay-submit="" lay-filter="demo2">提交修改</button>
                                    </div>
                                </div>
                            </div>

                        </form>
                    </div>
                </div>
            </div>

        </div>
    </div>

@endsection
@section('script')
    <script type="text/javascript" src="{{ asset('js/fontawesome-iconpicker.min.js') }}"></script>
    <script>
        $(function () {
            $(".iconpicker-input").iconpicker();

            $(".layui-btn")
        })
    </script>
@endsection